<?php
/**
 * 团购视图
 * @author tangbl
 *
 */
class GroupouViewModel extends ViewModel{
	
	public $viewFields = array(
		 
		'Product'=>array(
			'_type'=>'LEFT',
			'isdel',
			'lang',
			'solevar',
			'unit',
			'package',
			'weight',
			'title',
			'recnum',
			'description',
			'type',
			'jifen',
		),
		
		'Groupou'=>array(
				'id',
				'solevar'=>'slvar',
				'pid',
				'mprice',
				'sprice',
				'expire',
				'begintime',
				'endtime',
				'refund',
				'buynum',
				'pernum',
				'total',
				'prompt',
				'summary',
				'sort',
				'addtime',
				'addid',
			'_on'=>'Product.id=Groupou.pid'
		)
			
	 );
	
	/**
	 * 获取确认订单的商品列表
	 */
	public function getConfirmList($select){
	
		$id   = $select[0];
		$num  = $select[1];
		
		$map   = array("pid"=>$id);
		$list  = $this->where($map)->find(); 
		$total = intval($num) * doubleval($list['sprice']);
		$weight= intval($num) * intval($list['weight']);
		
		$list['num']    = $num;
		$array['amount']= $num;
		$array['weight']= $weight;
		$array['total'] = $total;
		$array['list']  = array($list);
	
		return $array;
	}
}
?>